<%@ page import="java.net.URLEncoder" %>
<%@ page import="com.touzi.proconfig.ProjectConfig" %>
<%@ page import="com.touzi.constants.DbCons" %>
<%@ page import="org.apache.ibatis.session.SqlSessionFactory" %>
<%@ page import="org.apache.ibatis.session.SqlSession" %>
<%@ page import="com.touzi.mapper.TongjiMapper" %>
<%@ page import="java.util.List" %>
<%@ page import="com.touzi.beans.dbs.tongji.ChanPinXiaoliang" %>
<%@ page import="com.touzi.mapper.SysconfigMapper" %><%--
  Created by IntelliJ IDEA.
  User: w7851
  Date: 2018/5/20
  Time: 20:33
  To change this template use File | Settings | File Templates.
  系统状态
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib uri="http://java.sun.com/jstl/core_rt" prefix="c" %>
<%
    boolean isok = false;

    try {
        isok = (boolean) session.getAttribute("isok");
    } catch (Exception e) {

    }

    if (!isok) {
        String msg = "登陆失效，请退出后重新登陆！";
        response.sendRedirect("/admdeskjsps/msg.jsp?msg=" + URLEncoder.encode(msg, "utf-8"));
        return;
    }
    String username = (String) session.getAttribute("user");

    String yiji = ProjectConfig.yiYongjin + ""; //
    String erji = ProjectConfig.erYongjin + ""; //
    String sanji = ProjectConfig.sanYongjin + ""; //

    SqlSession sqlSession = ((SqlSessionFactory) application.getAttribute(DbCons.DB_FACTORY)).openSession();
    TongjiMapper tongjiMapper = sqlSession.getMapper(TongjiMapper.class);
    SysconfigMapper sysconfigMapper = sqlSession.getMapper(SysconfigMapper.class);

    List<ChanPinXiaoliang> xiaoliangs = tongjiMapper.tongjiDdByCp(); //
    String leijiYingshou = tongjiMapper.leijiYingshou(); //
    String leijiTixian = tongjiMapper.leijiTixian();//
    String jinriYingshou = tongjiMapper.jinriYingshou(); //
    String jinriTixian = tongjiMapper.jinriTixian(); //
    String cantikuan = sysconfigMapper.findConfBykey("cantixian");
    String baseurl=sysconfigMapper.getBaseURL(); //

    request.setAttribute("chanpinxiaoliang", xiaoliangs);
    sqlSession.close();

    String path=application.getContextPath();
%>
<html>
<head>
    <title>Title</title>
    <meta charset="utf-8">
    <link rel="stylesheet" href="/layui/css/layui.css" media="all">
    <style>
        body {
            margin: 0px;
            padding: 8px;
        }

        #content {
            padding: 8px;
            border: 1px solid black;
            margin: auto;
        }

        .detail {
            margin: 0px;
            padding: 4px;
            border: solid 1px black;
            margin: 4px;
        }
    </style>
</head>
<body>

<div id="content">
    <p>欢迎使用，这里是系统运行的一些状态参数：</p>
    <p class="detail">分销佣金：【一级 <%=yiji%>】 【二级 <%=erji%>】 【三级 <%=sanji%>】
    </p>
    <div class="detail">
        当前域名:<%=baseurl%>  <button id="xgym">修改域名</button>
    </div>

    <div class="detail">
        支付宝接口：  <button id="xgzfb">修改支付宝参数</button>
    </div>

    <p class="detail">各类产品销售量：<c:forEach items="${chanpinxiaoliang}" var="item">
        【产品编号：${item.chanpinid} 销量：${item.shuliang}】
    </c:forEach>
    </p>
    <p class="detail">【累计营收:<%=leijiYingshou%>】 【累计提现:<%=leijiTixian%>】
    </p>
    <p class="detail">【今日营收:<%=jinriYingshou%>】 【今日提现:<%=jinriTixian%>】</p>
    <p class="detail">允许用户提款:<%=cantikuan%>&nbsp;&nbsp;&nbsp;<button id="xgtk">修改</button>
    </p>

    <div class="detail">
        <form action="/admdeskjsps/alipayquery.jsp" method="get">
            <input type="hidden" value="buyorder" name="type">
            通过支付宝服务器查询用户购买订单:<input type="text" name="out_no" autocomplete="off" style="width: 300px"><input type="submit">
        </form>
    </div>
    <div class="detail">
        <form action="/admdeskjsps/alipayquery.jsp" method="get">
            <input type="hidden" value="transorder" name="type">
            通过支付宝服务器查询用户提现订单:<input type="text" name="out_no" autocomplete="off" style="width: 300px"><input type="submit">
        </form>
    </div>
</div>

</body>
<script src="/layui/layui.js"></script>
<script>

    function xiugaitikuan() {
        console.log("btn clicked");
        layer.open({
            type: 2,
            content: "/admdeskjsps/xiugaiyxtk.jsp",
            area: ['430px', '400px'],
            offset: 'auto'
        });
    }

    function xiugaiyuming() {
        console.log("btn clicked");
        layer.open({
            type: 2,
            content: "/admdeskjsps/xiugaiyuming.jsp",
            area: ['430px', '400px'],
            offset: 'auto'
        });
    }

    function xiugaizhifubao() {
        console.log("btn clicked");
        layer.open({
            type: 2,
            content: "/admdeskjsps/xiugaizhifubao.jsp",
            area: ['430px', '400px'],
            offset: 'auto'
        });
    }

    layui.use('layer', function () {
        var layer = layui.layer;
        var $ = layui.$;

        $("#xgtk").click(xiugaitikuan);
        $("#xgym").click(xiugaiyuming);
        $("#xgzfb").click(xiugaizhifubao);
    });

</script>
</html>
